/*
 * Copyright (c) 2018 - 2019, AEye, Inc.
 * All rights reserved.
 */


#ifndef SOCKETHAWKEYEREADER_HPP
#define SOCKETHAWKEYEREADER_HPP

#include <atomic>
#include <cstddef>
#include <cstdint>
#include <string>

#include "HawkeyeFrame.hpp"
#include "QueueManager.hpp"
#include "SocketReaderDetail.hpp"

namespace aeye {

class SocketHawkeyeReader {
public:
  /*
   * pass the config in , also the port this particular reader should use
   * passing config is because it has list of all sensor ip addresses.
   * we use this later to filter invalid ip addr passd to process_packet.
   * probably will get rid of this later , it's a relic of there being only
   * one socketCloudReader.
   */
  SocketHawkeyeReader(const std::string& sensorAddr, uint16_t clientPort, bool udpBroadcastMode);
  ~SocketHawkeyeReader() noexcept;

  void run();
  void start();
  void stop() noexcept;
  HawkeyeFrame pop();
private:
  std::string sensorAddress;
  std::atomic<bool> isRunning{false};
  Reader reader_;
  QueueManager<HawkeyeFrame, QueueType::Overwriting> frame_queue_manager_;

  static constexpr size_t  maxQueueSize = 3;
};

}


#endif //SOCKETHAWKEYEREADER_HPP
